 package handling.netty;

 import tools.BitTools;
















 public class MapleCustomEncryption
 {
   public static byte[] encryptData(byte[] data) {
/*  23 */     for (int j = 0; j < 6; j++) {
/*  24 */       byte remember = 0;
/*  25 */       byte dataLength = (byte)(data.length & 0xFF);

/*  27 */       if (j % 2 == 0) {
/*  28 */         for (int i = 0; i < data.length; i++) {
/*  29 */           byte cur = data[i];
/*  30 */           cur = BitTools.rollLeft(cur, 3);
/*  31 */           cur = (byte)(cur + dataLength);
/*  32 */           cur = (byte)(cur ^ remember);
/*  33 */           remember = cur;
/*  34 */           cur = BitTools.rollRight(cur, dataLength & 0xFF);
/*  35 */           cur = (byte)((cur ^ 0xFFFFFFFF) & 0xFF);
/*  36 */           cur = (byte)(cur + 72);
/*  37 */           dataLength = (byte)(dataLength - 1);
/*  38 */           data[i] = cur;
         }
       } else {
/*  41 */         for (int i = data.length - 1; i >= 0; i--) {
/*  42 */           byte cur = data[i];
/*  43 */           cur = BitTools.rollLeft(cur, 4);
/*  44 */           cur = (byte)(cur + dataLength);
/*  45 */           cur = (byte)(cur ^ remember);
/*  46 */           remember = cur;
/*  47 */           cur = (byte)(cur ^ 0x13);
/*  48 */           cur = BitTools.rollRight(cur, 3);
/*  49 */           dataLength = (byte)(dataLength - 1);
/*  50 */           data[i] = cur;
         }
       }
     }

/*  55 */     return data;
   }

   public static byte[] Encrypt(byte[] buffer, byte[] iv) {
/*  59 */     byte[] ret = new byte[buffer.length];
/*  60 */     int i = 0;
/*  61 */     while (i < buffer.length) {
/*  62 */       int n = i++;
/*  63 */       buffer[n] = (byte)(buffer[n] + iv[0]);
     }
/*  65 */     return ret;
   }











   public static byte[] decryptData(byte[] data) {
/*  79 */     for (int j = 1; j <= 6; j++) {
/*  80 */       byte remember = 0;
/*  81 */       byte dataLength = (byte)(data.length & 0xFF);
/*  82 */       byte nextRemember = 0;

/*  84 */       if (j % 2 == 0) {
/*  85 */         for (int i = 0; i < data.length; i++) {
/*  86 */           byte cur = data[i];
/*  87 */           cur = (byte)(cur - 72);
/*  88 */           cur = (byte)((cur ^ 0xFFFFFFFF) & 0xFF);
/*  89 */           cur = BitTools.rollLeft(cur, dataLength & 0xFF);
/*  90 */           nextRemember = cur;
/*  91 */           cur = (byte)(cur ^ remember);
/*  92 */           remember = nextRemember;
/*  93 */           cur = (byte)(cur - dataLength);
/*  94 */           cur = BitTools.rollRight(cur, 3);
/*  95 */           data[i] = cur;
/*  96 */           dataLength = (byte)(dataLength - 1);
         }
       } else {
/*  99 */         for (int i = data.length - 1; i >= 0; i--) {
/* 100 */           byte cur = data[i];
/* 101 */           cur = BitTools.rollLeft(cur, 3);
/* 102 */           cur = (byte)(cur ^ 0x13);
/* 103 */           nextRemember = cur;
/* 104 */           cur = (byte)(cur ^ remember);
/* 105 */           remember = nextRemember;
/* 106 */           cur = (byte)(cur - dataLength);
/* 107 */           cur = BitTools.rollRight(cur, 4);
/* 108 */           data[i] = cur;
/* 109 */           dataLength = (byte)(dataLength - 1);
         }
       }
     }

/* 114 */     return data;
   }
 }


/* Location:              C:\PGX\Server.jar!\handling\netty\MapleCustomEncryption.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */